package com.ontheroad.mysql.group.service;

import java.util.Date;
import java.util.HashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.modoumama.service.base.impl.BaseServiceImpl;

import com.ontheroad.group.model.SceneGroupEntity;
import com.ontheroad.group.model.TimingGroupEntity;
import com.ontheroad.group.service.TimingGroupService;
import com.ontheroad.mysql.group.mapper.SceneGroupMapper;
import com.ontheroad.mysql.group.mapper.TimingGroupMapper;
import com.ontheroad.utils.UUIDUtil;

/*import com.ontheroad.utils.SmsUtil;*/

/**
 * Created by kedong on 2017/6/25 0021.
 */
@Service
@Transactional
public class TimingGroupServiceImpl extends BaseServiceImpl<TimingGroupEntity, Integer>
		implements TimingGroupService {

	private Logger log = LoggerFactory.getLogger(getClass());

	@Autowired
	private TimingGroupMapper timingGroupMapper;

	@Autowired
	private SceneGroupMapper sceneGroupMapper;

	public HashMap<String, Object> insertTimingGroup(int sceneId,
			TimingGroupEntity timingGroupEntity) throws Exception {
			HashMap<String, Object> bean = new HashMap<String, Object>();
			log.info("添加定时组合信息");
			SceneGroupEntity sceneGroupEntity=new SceneGroupEntity();
			sceneGroupEntity.setSceneId(sceneId);
			sceneGroupEntity.setTimingGroupId(timingGroupEntity.getId());
			sceneGroupEntity.setId(UUIDUtil.generate());
			sceneGroupMapper.insertModel(sceneGroupEntity);
			timingGroupEntity.setCreateTime(new Date());
			timingGroupMapper.insertModel(timingGroupEntity);
			bean.put("timing", timingGroupEntity);
			return bean;
	}

}
